package com.example.demo.handler;

import com.example.demo.dto.ResultDTO;
import com.example.demo.dto.ResultDTOBuilder;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionHandler {

    @org.springframework.web.bind.annotation.ExceptionHandler(Exception.class)
    public ResultDTO handler(Exception e){
        System.out.println("异常拦截器拦截,"+e.getLocalizedMessage());
        return ResultDTOBuilder.selfSetting("error","500",e.getLocalizedMessage(),null);
    }
}
